<?PHP

require_once("./include/membersite_config.php");
//include_once dirname(dirname(__FILE__)) . "/clases/common.php";


if(isset($_POST['submitted']))
{
   if($fgmembersite->RegisterUser())
   {
        $fgmembersite->RedirectToURL("thank-you.html");
   }
}



require ("../clases/configMysql.php");

$core = dirname(dirname(__FILE__)) . '/clases/xajax/xajax_core';
require_once $core . '/xajax.inc.php';



$xajax = new xajax();
$xajax->configure('allowAllResponseTypes', true);
$xajax->configure('useUncompressedScripts', true);
$xajax->configure("javascript URI", '../clases/xajax' );
$xajax->register(XAJAX_FUNCTION, "helloWorld",
	array(
		'mode' => '"synchronous"',
		'responseProcessor' => 'textResponse'
		));

$xajax->processRequest();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    
    <title><?php echo $lang['title_reg'];?></title>
    <?php
	// output the xajax javascript. This must be called between the head tags
	$xajax->printJavascript();
?>
    <link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css" />
    
    
   
    
    <script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
    <link rel="STYLESHEET" type="text/css" href="style/pwdwidget.css" />
    <script src="scripts/pwdwidget.js" type="text/javascript"></script>      
</head>
<body>

<!-- Form Code Start -->
<div id='fg_membersite'>
<form id='register' action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
<fieldset >
<legend><?php echo $lang['title_reg'];?></legend>

<input type='hidden' name='submitted' id='submitted' value='1'/>

<div class='short_explanation'><?php echo $lang['req_field'];?></div>
<input type='text'  class='spmhidip' name='<?php echo $fgmembersite->GetSpamTrapInputName(); ?>' />

<div><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span></div>

<!-- 
<div class='container'>
    <label for='name' ><?php //echo $lang['full_name'];?> </label><br/>
    <input type='text' name='name' id='name' value='<?php// echo $fgmembersite->SafeDisplay('name') ?>' maxlength="50" /><br/>
    <span id='register_name_errorloc' class='error'></span>
</div>

 -->
<div class='container'>
    <label for='first_name' ><?php echo $lang['first_name'];?> </label><br/>
    <input type='text' name='name' id='name' value='<?php echo $fgmembersite->SafeDisplay('name') ?>' maxlength="50" /><br/>
    <span id='register_name_errorloc' class='error'></span>
</div>

<div class='container'>
    <label for='last_name' ><?php echo $lang['last_name'];?> </label><br/>
    <input type='text' name='last_name' id='last_name' value='<?php echo $fgmembersite->SafeDisplay('last_name') ?>' maxlength="50" /><br/>
    <span id='register_last_name_errorloc' class='error'></span>
</div>




<div class='container'>
    <label for='grupo' ><?php echo $lang['grupo'];?></label><br/>
    <!-- <input type='text' name='grupo' id='grupo' value='<?php echo $fgmembersite->SafeDisplay('grupo') ?>' maxlength="50" /><br/> -->
    <select  name='grupo' id='grupo'  >
    	<option value="0">---</option>
    	<?php 
    	
  
    	$res=$Db->query("select * from grupo");
    	
    	
    	for($i=0;$i<count($res);$i++)
    	{
    		echo "<option value=\"".$res[$i]['grupo']['id_grupo']."\">".$res[$i]['grupo']['nombre_grupo']."</option>";
    	}
    	

    	?>
    	
    </select>
    
    <span id='register_grupo_errorloc' class='error'></span>
</div>



<div class='container'>
    <label for='email' ><?php echo $lang['e-mail']?></label><br/>
    <input type='text' name='email' id='email' value='<?php echo $fgmembersite->SafeDisplay('email') ?>' maxlength="50" /><br/>
    <span id='register_email_errorloc' class='error'></span>
</div>




<div class='container'>
    <label for='telefono' ><?php echo $lang['tel']?></label><br/>
    <input type='text' name='telefono' id='telefono' value='<?php echo $fgmembersite->SafeDisplay('telefono') ?>' maxlength="50" /><br/>
    <span id='register_telefono_errorloc' class='error'></span>
</div>


<div class='container'>
    <label for='movile' ><?php echo $lang['movil']?></label><br/>
    <input type='text' name='movile' id='movile' value='<?php echo $fgmembersite->SafeDisplay('movile') ?>' maxlength="50" /><br/>
    <span id='register_movile_errorloc' class='error'></span>
</div>


<div class='container'>
    <label for='username' ><?php echo $lang['user_name'];?></label><br/>
    <input type='text' name='username' id='username' value='<?php echo $fgmembersite->SafeDisplay('username') ?>' maxlength="50" /><br/>
    <span id='register_username_errorloc' class='error'></span>
</div>


<div class='container' style='height:80px;'>
    <label for='password' ><?php echo $lang['pwd'];?></label><br/>
    <div class='pwdwidgetdiv' id='thepwddiv' ></div>
    <noscript>
    <input type='password' name='password' id='password' maxlength="50" />
    </noscript>    
    <div id='register_password_errorloc' class='error' style='clear:both'></div>
</div>



<div class='container' style='height:80px;'>
    <label for='repassword' ><?php echo $lang['repwd'];?></label><br/>
   
   
    <input type='password' name='repassword' id='repassword' maxlength="50" onkeyup="DoCustomValidation()"/>
     
    <div id='register_repassword_errorloc' class='error' style='clear:both'></div>
</div>


<div class='container'>
    <input type='submit' name='Submit' value='Submit' />
</div>

</fieldset>
</form>
<!-- client-side Form Validations:
Uses the excellent form validation script from JavaScript-coder.com-->

<script type='text/javascript'>
// <![CDATA[
          
    function DoCustomValidation()
{
  var frm = document.forms["register"];
  
  
  if(frm.password.value != frm.repassword.value)
  {

document.getElementById("register_repassword_errorloc").innerHTML="<?php echo $lang['req_not_same']?>";
	    
    return false;
  }
  
  else
  {
	  document.getElementById("register_repassword_errorloc").innerHTML="";
    return true;
  }
}
    
    var pwdwidget = new PasswordWidget('thepwddiv','password',<?php echo "'".$lang['txt_show']."','".$lang['txt_mask']."','".$lang['txt_weak']."','".$lang['txt_medium']."','".$lang['txt_good']."'"?>);
     
     pwdwidget.MakePWDWidget();

   
   
    var frmvalidator  = new Validator("register");
    frmvalidator.EnableOnPageErrorDisplay();
    frmvalidator.EnableMsgsTogether();
  

    
    frmvalidator.addValidation("name","req","<?php echo $lang['req_name']?>");

    frmvalidator.addValidation("last_name","req","<?php echo $lang['req_last_name']?>");

    frmvalidator.addValidation("email","req","<?php echo $lang['req_mail']?>");

    frmvalidator.addValidation("email","email","<?php echo $lang['valid_mail']?>");

    frmvalidator.addValidation("grupo","dontselect=0","<?php echo $lang['req_group']?>");

    frmvalidator.addValidation("username","req","<?php echo $lang['req_user']?>");
    
    frmvalidator.addValidation("password","req","<?php echo $lang['req_pass']?>");

   

// ]]>
</script>

<!--
Form Code End (see html-form-guide.com for more info.)
 <button onclick="alert(xajax.request({xjxfun:'helloWorld'})); " >Click Me</button> -->

 	
</body>
</html>